<!--  -->
<template>
  <div class="uploadOpt">
    <el-form :inline="true" class="demo-form-inline">
      <el-form-item>
        <el-button size="small" type="primary" @click="upload" :disabled="uploadLoading">
          {{uploadLoading?'Loading...':'点击上传'}}</el-button>
        <el-button size="small" type="primary" @click="createFolder" style="margin-left:10px;">创建文件夹</el-button>
        <el-button size="small" type="success" @click="resetDataTable" style="margin-left:10px;">刷新</el-button>
      </el-form-item>
    </el-form>
    <VirtualFolderFileUpload ref="virtualFolderFileUpload" :finish="complete" />
    <SaveFolderSimple ref="createFolder" :resetPageData='resetPageData'/>
  </div>
</template>

<script>
import VirtualFolderFileUpload from '@/components/common/upload/VirtualFolderFileUpload.vue'
import SaveFolderSimple from '@/components/main/user/virtualroot/SaveFolderSimple.vue'
export default {
  props: {
    // 改变加载数据的loading属性
    changeDataLoading: {
      type: Function
    },
    // 重置数据
    resetPageData: {
      type: Function
    },
    // 允许上传的文件限制信息
    uploadInfos: {
      type: Array
    },
    uploadLoading: {
      type: Boolean
    }
  },
  created () {
  },
  data () {
    return {
    }
  },
  methods: {
    upload () {
      if (this.uploadLoading) {
        return
      }
      // 调用子组件RepertoryUpload click() 方法
      this.$refs['virtualFolderFileUpload'].click(this.uploadInfos)
    },
    // 上传完成后
    complete () {
      this.resetPageData()
    },
    resetDataTable () {
      this.resetPageData()
    },
    createFolder () {
      this.$refs['createFolder'].create('创建文件夹')
    }
  },
  components: {
    VirtualFolderFileUpload,
    SaveFolderSimple
  }
}

</script>

<style scoped>
.uploadOpt /deep/ .el-form-item {
  margin-bottom: 13px;
}
</style>
